//
//  OptionScene.m
//  Bridge
//
//  Created by vinh pham on 5/11/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "OptionScene.h"
#import "MainScene.h"

@implementation OptionScene

- (id) init {
    self = [super init];
    if (self != nil) {
        CGSize winSize = [CCDirector sharedDirector].winSize;
        
        CCSprite *bg = [CCSprite spriteWithFile:[CCFileUtils fullPathFromRelativePath:@"bg_about.png"]];
        [bg setPosition:ccp(winSize.width/2,winSize.height/2)];
        [self addChild:bg];
        
        CCLabelBMFont *bgmLabel = [CCLabelBMFont labelWithString:@"BGM" fntFile:FONT_FILE];
        [bgmLabel setPosition:ccp(winSize.width/2,240)];
        [self addChild:bgmLabel];
        
        /* 
		 -- create BGM toogle menu --
		 */
        
		CCMenuItemImage *btnBGOn  = [CCMenuItemImage itemFromNormalImage:[CCFileUtils fullPathFromRelativePath:@"btn_on.png"] selectedImage:[CCFileUtils fullPathFromRelativePath:@"btn_on.png"]];
		CCMenuItemImage *btnBGOff = [CCMenuItemImage itemFromNormalImage:[CCFileUtils fullPathFromRelativePath:@"btn_off.png"] selectedImage:[CCFileUtils fullPathFromRelativePath:@"btn_off.png"]];
		CCMenuItemToggle *toogle1  = [CCMenuItemToggle itemWithTarget:self selector:@selector(switchBGM:) items:btnBGOff,btnBGOn,nil];
		
		CCMenu *menuBGM = [CCMenu menuWithItems:toogle1,nil];
		[menuBGM setPosition:ccp(bgmLabel.position.x+100,bgmLabel.position.y)];
		[self addChild:menuBGM];
		
        CCLabelBMFont *seLabel = [CCLabelBMFont labelWithString:@"SE" fntFile:FONT_FILE];
        [seLabel setPosition:ccp(winSize.width/2,160)];
        [self addChild:seLabel];
        
        /*
		 -- create SE toogle menu --
		 */
		
		CCMenuItemImage *btnSEOn  = [CCMenuItemImage itemFromNormalImage:[CCFileUtils fullPathFromRelativePath:@"btn_on.png"] selectedImage:[CCFileUtils fullPathFromRelativePath:@"btn_on.png"]];
		CCMenuItemImage *btnSEOff = [CCMenuItemImage itemFromNormalImage:[CCFileUtils fullPathFromRelativePath:@"btn_off.png"] selectedImage:[CCFileUtils fullPathFromRelativePath:@"btn_off.png"]];
		CCMenuItemToggle *toogle2  = [CCMenuItemToggle itemWithTarget:self selector:@selector(switchSE:) items:btnSEOff,btnSEOn,nil];
		
		CCMenu *menuSE = [CCMenu menuWithItems:toogle2,nil];
		[menuSE setPosition:ccp(seLabel.position.x+100,seLabel.position.y)];
		[self addChild:menuSE];
        
        CCLabelBMFont *backLabel = [CCLabelBMFont labelWithString:@"Back" fntFile:FONT_FILE];    
        
        CCMenuItemLabel *backItem = [CCMenuItemLabel itemWithLabel:backLabel target:self selector:@selector(backTapped:)];
        //restartItem.scale = 0.1;
        backItem.position = ccp(winSize.width/2, 100);
        
        CCMenu *menu = [CCMenu menuWithItems:backItem, nil];
        menu.position = CGPointZero;
        [self addChild:menu];
        
        [backItem runAction:[CCScaleTo actionWithDuration:0.5 scale:1.0]];
    }
    return self;
}

- (void) backTapped:(id)sender {
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFadeTR transitionWithDuration:1.0f scene:[MainScene node]]];
}

- (void) switchBGM:(id)sender {
    
}

- (void) switchSE:(id)sender {
    
}

@end
